package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.customer.domain.BusinessOrderSub;
import com.ktgj.customer.service.IBusinessOrderSubService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 订单子Controller
 * 
 * @author ruoyi
 * @date 2021-07-30
 */
@ControllerAdvice
@RestController
@RequestMapping("/businessOrderSub")
public class BusinessOrderSubController extends BaseController
{
    @Autowired
    private IBusinessOrderSubService businessOrderSubService;

    /**
     * 查询订单子列表
     */
    //@PreAuthorize(hasPermi = "customer:businessOrderSub:list")
    @GetMapping("/list")
    public TableDataInfo list(BusinessOrderSub businessOrderSub)
    {
        startPage();
        List<BusinessOrderSub> list = businessOrderSubService.selectBusinessOrderSubList(businessOrderSub);
        return getDataTable(list);
    }

    /**
     * 导出订单子列表
     */
    //@PreAuthorize(hasPermi = "customer:businessOrderSub:export")
    @Log(title = "订单子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusinessOrderSub businessOrderSub) throws IOException
    {
        List<BusinessOrderSub> list = businessOrderSubService.selectBusinessOrderSubList(businessOrderSub);
        ExcelUtil<BusinessOrderSub> util = new ExcelUtil<BusinessOrderSub>(BusinessOrderSub.class);
        util.exportExcel(response, list, "订单子数据");
    }

    /**
     * 获取订单子详细信息
     */
    //@PreAuthorize(hasPermi = "customer:businessOrderSub:query")
    @GetMapping(value = "/{orderSubId}")
    public AjaxResult getInfo(@PathVariable("orderSubId") Long orderSubId)
    {
        return AjaxResult.success(businessOrderSubService.selectBusinessOrderSubById(orderSubId));
    }

    /**
     * 新增订单子
     */
    //@PreAuthorize(hasPermi = "customer:businessOrderSub:add")
    @Log(title = "订单子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusinessOrderSub businessOrderSub)
    {
        return toAjax(businessOrderSubService.insertBusinessOrderSub(businessOrderSub));
    }

    /**
     * 修改订单子
     */
    //@PreAuthorize(hasPermi = "customer:businessOrderSub:edit")
    @Log(title = "订单子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusinessOrderSub businessOrderSub)
    {
        return toAjax(businessOrderSubService.updateBusinessOrderSub(businessOrderSub));
    }

    /**
     * 删除订单子
     */
    //@PreAuthorize(hasPermi = "customer:businessOrderSub:remove")
    @Log(title = "订单子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderSubIds}")
    public AjaxResult remove(@PathVariable Long[] orderSubIds)
    {
        return toAjax(businessOrderSubService.deleteBusinessOrderSubByIds(orderSubIds));
    }
}
